package com.sh.data.engine.domain.integration.datasource.model.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * 数据源连接状态
 *
 * @author: mengzheng.mhc
 * @date: 2024/5/30 16:25
 */
@Getter
public enum DSStatus {

    FAILED(0, "连接失败"),
    CONNECTED(1, "连接成功");

    private final int code;

    private final String desc;

    DSStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static DSStatus from(Integer code) {
        return Arrays.stream(DSStatus.values())
            .filter(e -> e.code == code)
            .findFirst()
            .orElse(null);
    }
}
